package com.clc.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.Servlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.clc.bean.Users;
import com.clc.service.IUserService;

@Controller
@RequestMapping("/test")
public class HelloMavenController {
	static Log log = LogFactory.getLog(HelloMavenController.class.getName());
	@Autowired
	private IUserService userService;
	
	
	@RequestMapping(value="/index.do")
    public ModelAndView excuteAction(HttpServletRequest request, HttpServletResponse response)  
    		 throws Exception {
		Users user = userService.findUserById(1);
		//org.springframework.web.
       // System.out.println("index.jsp");
		log.info(user.getUserName());
		ModelAndView medelView = new ModelAndView("mavenTest");
		Map modelMap = new HashMap();  
		modelMap.put("msg", "mavenTest");  
		modelMap.put("time", new Date());
		modelMap.put("user", user);  
		medelView.addAllObjects(modelMap);
		return medelView;
    } 

	@RequestMapping(value="/login.do")
    public ModelAndView login(HttpServletRequest request, HttpServletResponse response)  
    		 throws Exception {
		ModelAndView medelView = new ModelAndView("mavenTest");
		Map modelMap = new HashMap();  
		modelMap.put("msg", "mavenTest");  
		modelMap.put("time", new Date());
		medelView.addAllObjects(modelMap);
		return medelView;
	}
	
}
